﻿using System;
using Microsoft.Popfly.GameCreator.Collections;

namespace Microsoft.Popfly.GameCreator.Data
{
    public class MotionInfo
    {
        public enum ContinueMovingValues
        {
            NotDefined,
            Forever,
            WhileReceiving,
            ForDuration,
            ForDistance
        }
        public enum DirectionValues
        {
            NotDefined,
            N,
            S,
            E,
            W,
            NE,
            NW,
            SE,
            SW
        }
        public enum RelativeValues
        {
            NotDefined,
            Scene,
            Self,
            Point,
            Actor,
            Mouse
        }
        public enum ModifiesValues
        {
            NotDefined,
            MaxSpeed,
            Acceleration,
            Velocity
        }

        
        [GameXamlProperty]
        public String Type;
        [GameXamlProperty]
        public ContinueMovingValues ContinueMoving;
        [GameXamlProperty]
        public DirectionValues Direction;
        [GameXamlProperty]
        public Double Distance;
        [GameXamlProperty]
        public Double Duration;
        [GameXamlProperty]
        public String Transform;
        [GameXamlProperty]
        public Boolean IgnoreMouseX;
        [GameXamlProperty]
        public Boolean IgnoreMouseY;
        [GameXamlProperty]
        public RelativeValues Relative;
        [GameXamlProperty]
        public Boolean AutoReverse;
        [GameXamlProperty]
        public String Repeat;
        [GameXamlProperty]
        public ModifiesValues Modifies;
        [GameXamlProperty]
        public Double MaxSpeed;
        [GameXamlProperty]
        public Double Acceleration;
        [GameXamlProperty]
        public Double VelocityJump;
        [GameXamlProperty]
        public String SubType;
        [GameXamlProperty]
        public String Scene;

        [GameXamlProperty]
        public Double TargetPointX;
        [GameXamlProperty]
        public Double TargetPointY;


        [GameXamlProperty(nodeName = "Includes", dictionaryEntryNodeName = "Include", dictionaryHashAttributeName = "Value", objectType = typeof(IncludeObjectInfo))]
        public OrderedDictionary<String, IncludeObjectInfo> Includes;

        public MotionInfo Copy()
        {
            MotionInfo retVal = new MotionInfo();
            retVal.Acceleration = Acceleration;
            retVal.AutoReverse = AutoReverse;
            retVal.ContinueMoving = ContinueMoving;
            retVal.Direction = Direction;
            retVal.Distance = Distance;
            retVal.Duration = Duration;
            retVal.IgnoreMouseX = IgnoreMouseX;
            retVal.IgnoreMouseY = IgnoreMouseY;
            retVal.MaxSpeed = MaxSpeed;
            retVal.Modifies = Modifies;
            retVal.Relative = Relative;
            retVal.Repeat = Repeat;
            retVal.Scene = Scene;
            retVal.SubType = SubType;
            retVal.Transform = Transform;
            retVal.Type = Type;
            retVal.VelocityJump = VelocityJump;
            retVal.TargetPointX = TargetPointX;
            retVal.TargetPointY = TargetPointY;
            if (Includes != null)
            {
                retVal.Includes = new OrderedDictionary<string, IncludeObjectInfo>();
                for (int i = 0; i < Includes.Count; i++)
                {
                    IncludeObjectInfo includeObject = new IncludeObjectInfo();
                    includeObject.Value = Includes.getIndexedValue(i).Value;
                    retVal.Includes.Add(Includes.getIndexedKey(i), includeObject);
                }
            }
            return retVal;
        }
    }
}
